import axios from 'axios';
import { Pagination, PaginationData } from '@/types/global';

export interface CommonProblemParams extends Pagination {
  keywords: string;
}

export interface CommonProblemVO {
  answer: string; // 回答
  content: string; // 问题内容
  createTime: string;
  id: string;
  title: string; // 问题标题
}
export interface CreateCommonProblemDTO {
  content: string; // 问题内容
  title: string; // 问题标题
}
export interface AnswerCommonProblemDTO {
  id: string;
  answer: string; // 回答
}

export function getFaqList(data: CommonProblemParams) {
  return axios.post<PaginationData<CommonProblemVO>>(
    'mdm/faq/getFaqList',
    data
  );
}
export function askingQuestion(data: CreateCommonProblemDTO) {
  return axios.post('mdm/faq/askingQuestion', data);
}
export function answerQuestion(data: AnswerCommonProblemDTO) {
  return axios.post('mdm/faq/answerQuestion', data);
}

export function getFaqDetail(id: string) {
  return axios.get<CommonProblemVO>(`mdm/faq/getFaqDetail?id=${id}`);
}
export function deleteFaq(id: string) {
  return axios.post(`mdm/faq/deleteFaq?id=${id}`);
}
